<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>后台管理面板</title>
  <!-- 告诉浏览器该页面是自适应布局 -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <include file="common/top" />
  <!--引入JS-->
  <script type="text/javascript" src="/static/admin/webuploader-0.1.5/webuploader.js"></script>
  <!-- UEditor配置文件 -->
  <script type="text/javascript" src="/static/admin/js/ueditor/ueditor.config.js"></script>
  <!-- UEditor编辑器源码文件 -->
  <script type="text/javascript" src="/static/admin/js/ueditor/ueditor.all.js"></script>
  <!-- wangEditor编辑器源码文件 -->
  <!--<script type="text/javascript" src="/static/wangEditor-3.1.1/release/wangEditor.min.js"></script>-->
  <!--<script type="text/javascript" src="/static/wangEditor-3.1.1/release/wangEditorExt.js"></script>-->
  <!-- ckeditor5编辑器源码文件 -->
  <!--<script type="text/javascript" src="/static/ckeditor5/ckeditor.js"></script>-->
  <!--<script type="text/javascript" src="/static/ckeditor5/translations/zh-cn.js"></script>-->
  <script type="text/javascript">
    //多图删除
	$(document).on('click','.remove_images',function(){
		var remove = $(this).parent().parent(); 
			remove.remove();
	})
  </script>
  <include file="common/upload" />
</head>
<body class="hold-transition skin-blue sidebar-mini">	
<div class="wrapper">
    <div class="content-wrapper" style="margin-left: 0 !important;">
        <!--页眉-->
        <section class="content-header">
          <h1>{{$lists?'修改':'添加'}}内容</h1>
        </section>
        <!--内容开始-->
        <section class="content">
            <div class="search">
            	<form class="form-inline" action="">
                 <input class="btn btn-flat btn-primary m_10_l_0" onclick="location.href='{{:url('index',['cid'=>$cid])}}'" type="button" value="显示全部">
                 <a class="btn btn-flat btn-success m_10 f_r" onclick="javascript :history.back(-1)"><i class="fa fa-undo m-r-10"></i>返 回</a>  
            	</form> 
            </div>
            <!--数据表开始-->
            <div class="row">
                <div class="col-xs-12">
                	<div class="box box-body">
                		<if condition="$lists">
                		<form method="post" action="{{:url('editsave')}}">
                			<input type="hidden" name="id" value="{{$lists.id}}"/>
                		<else />
                		<form method="post" action="{{:url('addsave')}}">
                		</if>
                        <input type="hidden" name="cid" value="{{$cid}}"/>
                            <volist name="fields" id="field">
		                	<!---->
		                	<div class="row dd_input_group">
			                	<div class="form-group">
                                  	<switch name='$field.type'>
                                    	<case value='title'>
                                           <label class="col-sm-1 col-xs-4 control-label dd_input_l">{{$field.name}}</label>
				                  		   <div class="col-sm-4 col-xs-8">
                                           <input type="text" name="{{$field.field}}" class="form-control" placeholder="请输入{{$field.name}}" value="{{$lists[$field.field]}}"> 
                                           </div>
				                 		   <div class="col-sm-4 dd_ts"><eq name="field.isrequire" value="1">* 必填</eq></div>
                                        </case>
                                    	<case value='cid'>
                                          <label class="col-sm-1 col-xs-4 control-label dd_input_l">{{$field.name}}</label>
                                          <div class="col-sm-4 col-xs-8">
                                            <select name="{{$field.field}}" class="form-control">
                                               <volist name="cate" id="cate_list">
                                                <option <eq name="$cid" value="$cate_list.id">selected</eq> value='{{$cate_list.id}}'
                                                <eq name="$mcode" value="$cate_list.mcode"><else/>disabled</eq>
                                                 >{{$cate_list.name}}</option>
                                                </volist>
                                          </select>
                                          </div>
                                          <div class="col-sm-4 dd_ts"><eq name="field.isrequire" value="1">* 必填</eq></div>
                                        </case>
                                        <case value='text'>
                                           <label class="col-sm-1 col-xs-4 control-label dd_input_l">{{$field.name}}</label>
				                  		   <div class="col-sm-4 col-xs-8">
                                           <input type="text" name="{{$field.field}}" class="form-control" placeholder="请输入{{$field.name}}" value="{{$lists[$field.field]}}"> 
                                           </div>
				                 		   <div class="col-sm-4 dd_ts"><eq name="field.isrequire" value="1">* 必填</eq></div>
                                        </case>
                                        <case value='textarea'>
                                          <div class="col-sm-5 col-xs-12">
                                          <label class="text-lable">{{$field.name}}</label>
                                          <textarea class="form-control" name="{{$field.field}}" rows="3" placeholder="请输入{{$field.name}}">{{$lists[$field.field]}}</textarea>
                                          </div>
                                          <div class="col-sm-4 dd_ts"><eq name="field.isrequire" value="1">* 必填</eq></div>
                                        </case>
                                        <case value='editor'>
                                        	<div class="col-sm-8 col-xs-8">
                                              <label class="text-lable">{{$field.name}}</label>
                                              </div>
                                              <div class="col-sm-8 col-xs-8">
                                                <!-- 加载编辑器的容器 -->
                                                <textarea name="{{$field.field}}" id="container_{{$field.field}}" style="width:100%;height:400px;">{{$lists[$field.field]}}</textarea>
                                                <!-- 实例化编辑器 -->
                                                <script type="text/javascript">
                                                    var container_{{$field.field}} = UE.getEditor('container_{{$field.field}}');
                                                </script>
                                              </div>
                                        </case>
                                        <case value='select'>
                                          <label class="col-sm-1 col-xs-4 control-label dd_input_l">{{$field.name}}</label>
                                          <div class="col-sm-4 col-xs-8">
                                            <select name="{{$field.field}}" class="form-control" >
                                                <foreach name='$field.setup.options' item='v' >
                                                <if condition='$lists'>
                                                <option <eq name="$lists[$field.field]" value="$v.1">selected</eq> value='{{$v.1}}' >{{$v.0}}</option>
                                                <else />
                                                <option <eq name="$field.setup.default" value="$v.1">selected</eq> value='{{$v.1}}' >{{$v.0}}</option>
                                                </if>
                                                </foreach>
                                          </select>
                                          </div>
                                          <div class="col-sm-4 dd_ts"><eq name="field.isrequire" value="1">* 必填</eq></div>
                                        </case>
                                        <case value='radio'>
                                          <label class="col-sm-1 col-xs-4 control-label dd_input_l">{{$field.name}}</label>
                                          <div class="col-sm-4 col-xs-8">
                                          <div class="dd_radio_lable_left">
                                          	<foreach name='$field.setup.options' item='v' >
                                            <label class="dd_radio_lable">
                                              <if condition='$lists'>
                                              <input type="radio" name="{{$field.field}}" value="{{$v.1}}" class="dd_radio" <eq name="$lists[$field.field]" value="$v.1">checked</eq>><span>{{$v.0}}</span>
                                               <else />
                                               <input type="radio" name="{{$field.field}}" value="{{$v.1}}" class="dd_radio" <eq name="$field.setup.default" value="$v.1">checked</eq>><span>{{$v.0}}</span>
                                               </if>
                                            </label>
                                            </foreach>
                                           </div>
                                          </div>
                                          <div class="col-sm-4 dd_ts"><eq name="field.isrequire" value="1">* 必填</eq></div>
                                        </case>
                                        <case value='checkbox'>
                                          <label class="col-sm-1 col-xs-4 control-label dd_input_l">{{$field.name}}</label>
                                          <div class="col-sm-4 col-xs-8">
                                          <div class="dd_radio_lable_left">
                                          	<foreach name='$field.setup.options' item='v' >
                                            <label class="dd_radio_lable">
                                              <if condition='$lists'>
                                              <input type="checkbox" name="{{$field.field}}[]" value="{{$v.1}}" class="dd_radio"
                                              <in name="$v.1" value="$lists[$field.field]">checked</in>
                                               ><span>{{$v.0}}</span>
                                               <else />
                                               <input type="checkbox" name="{{$field.field}}[]" value="{{$v.1}}" class="dd_radio" <in name="$v.1" value="$field.setup.default">checked</in>><span>{{$v.0}}</span>
                                               </if>
                                            </label>
                                            </foreach>
                                           </div>
                                          </div>
                                          <div class="col-sm-4 dd_ts"><eq name="field.isrequire" value="1">* 必填</eq></div>
                                        </case>
                                        <case value='image'>
                                        	<label class="col-sm-1 col-xs-4 control-label dd_input_l">{{$field.name}}</label>
                                              <div class="col-sm-4 col-xs-8">
                                                <input type="text" name="{{$field.field}}" class="form-control" placeholder="请点击按钮上传或手动输入地址" value="{{$lists[$field.field]}}">
                                              </div>
                                              <div class="col-sm-4 dd_ts">
                                                <!--上传图片-->
                                                <!--用来存放item-->
                                                <div id="fileList_image{{$field.field}}" class="uploader-list">
                                                </div>
                                                <div id="filePicker_image{{$field.field}}"><i class="fa fa-upload m-r-10"></i>选择图片</div>
                                                <img class="image_preview" src="{{$lists[$field.field]?$lists[$field.field]:'/static/admin/images/nopic.png'}}" id="image_preview{{$field.field}}">
                                                <!--上传图片-->
                                                <eq name="field.isrequire" value="1"><span class="image_preview"> * 必填</span></eq>
                                              </div>
                                              <script>webupload('fileList_image{{$field.field}}','filePicker_image{{$field.field}}','image_preview{{$field.field}}','{{$field.field}}',false ,'{{$field.setup.upload_allowext}}');	</script>
                                        </case>
                                        <case value='images'>
                                          <div class="col-sm-5 col-xs-12">
                                          <label class="text-lable">{{$field.name}}</label>
                                          	<div class="more_images dd_ts">
                                            	<div id="more_images_{{$field.field}}">
                                                	<!---->
                                                    <if condition='$lists[$field.field]'>
                                                    <foreach name='$lists[$field.field]' item='vo'> 
                                                    <div class="row"><div class="col-xs-6"><input type="text" name="{{$field.field}}[]" value="{{$vo.image}}" class="form-control"></div> <div class="col-xs-3"><input class="form-control input-sm" type="text" name="{{$field.field}}_title[]" value="{{$vo.title}}"></div> <div class="col-xs-3"><button type="button" class="btn btn-block btn-warning remove_images">移除</button></div></div>
                                                    </foreach>
                                                    </if>
                                                    <!---->
                                                </div>
                                            </div>
                                          </div>
                                          <div class="col-sm-4 dd_ts">
                                                <!--上传图片-->
                                                <!--用来存放item-->
                                                <div id="fileList_image{{$field.field}}" class="uploader-list">
                                                </div>
                                                <div id="filePicker_image{{$field.field}}"><i class="fa fa-upload m-r-10"></i>选择图片</div>
                                                <!--上传图片-->
                                                <script>webupload('fileList_image{{$field.field}}','filePicker_image{{$field.field}}','image_preview{{$field.field}}','{{$field.field}}',true ,'{{$field.setup.upload_allowext}}');	</script>
                                                <eq name="field.isrequire" value="1"><span class="image_preview"> * 必填</span></eq>
                                              </div>
                                        </case>
                                        <case value='file'>
                                        	<label class="col-sm-1 col-xs-4 control-label dd_input_l">{{$field.name}}</label>
                                              <div class="col-sm-4 col-xs-8">
                                                <input type="text" name="{{$field.field}}" class="form-control" placeholder="请点击按钮上传或手动输入地址" value="{{$lists[$field.field]}}">
                                              </div>
                                              <div class="col-sm-4 dd_ts">
                                                <!--上传图片-->
                                                <!--用来存放item-->
                                                <div id="fileList_image{{$field.field}}" class="uploader-list">
                                                </div>
                                                <div id="filePicker_image{{$field.field}}"><i class="fa fa-upload m-r-10"></i>选择文件</div>
                                                <eq name="field.isrequire" value="1"><span class="image_preview"> * 必填</span></eq>
                                                <!--上传图片-->
                                              </div>
                                              <script>webupload('fileList_image{{$field.field}}','filePicker_image{{$field.field}}','image_preview{{$field.field}}','{{$field.field}}',false ,'{{$field.setup.upload_allowext}}');	</script>
                                              
                                        </case>
                                        <case value='number'>
                                        	<label class="col-sm-1 col-xs-4 control-label dd_input_l">{{$field.name}}</label>
				                  		   <div class="col-sm-4 col-xs-8">
                                           <input type="number" name="{{$field.field}}" class="form-control" placeholder="请输入{{$field.name}}" value="{{$lists[$field.field]?$lists[$field.field]:$field.setup.default}}"> 
                                           </div>
				                 		   <div class="col-sm-4 dd_ts"><eq name="field.isrequire" value="1">* 必填</eq></div>
                                        </case>
                                        <case value='datetime'>
                                        	<label class="col-sm-1 col-xs-4 control-label dd_input_l">{{$field.name}}</label>
				                  		   <div class="col-sm-4 col-xs-8">
                                           <input type="text" name="{{$field.field}}" class="form-control" placeholder="请输入{{$field.name}}" value="<if condition='$lists'>{$lists[$field.field]|date="Y-m-d H:i:s"><else/>{{$time}}</if>" id="datepicker_{{$field.field}}"> 
                                           
                                           </div>
				                 		   <div class="col-sm-4 dd_ts"><eq name="field.isrequire" value="1">* 必填</eq></div>
                                        	<script>
											$(function(){
												$('#datepicker_{{$field.field}}').datetimepicker({
												  autoclose: 1,
												  format:"yyyy-mm-dd hh:ii:ss",
												  language: "zh-CN",
												  todayHighlight: 1,//今天高亮
												})	
											})
											</script>
                                        </case>
                                        {case template}
                                          <label class="col-sm-1 col-xs-4 control-label dd_input_l">{$field.name}</label>
                                          <div class="col-sm-4 col-xs-8">
                                            <select name="{$field.field}" class="form-control" >
                                            	<option value="">请选择</option>
                                                {foreach $template.show as $k=>$v }
                                                <option {if $lists[$field.field] == trim($v)}selected{/if} value='{$v}' >{$v}</option>
                                                {/foreach}
                                          </select>
                                          </div>
                                          <div class="col-sm-4 dd_ts">{eq name="$field.required" value="1"}* 必填{/eq}默认延用栏目设置的模版</div>
                                        {/case}
				                    	{default /}	
                                    </switch>
				                  
				                </div>
			                </div>
			                <!---->
                            </volist>
		                	
			                <div class="row dd_input_group">
			                	<div class="form-group">
				                  <label class="col-sm-1 col-xs-4 control-label"></label>
				                  <div class="col-sm-4 col-xs-8">
				                    	<button type="submit" class="btn btn-flat btn-primary ">提 交</button> 
				                    	<button type="button" class="btn btn-flat btn-default" onclick="javascript :history.back(-1)">返 回</button>
				                  </div>
		
				                </div>
			                </div>
                		</form>
                 </div>
                  <!-- /.box -->
                </div>
              </div>
            <!--数据表结束-->
        </section>
        <!-- right col -->
      </div>
      <!-- /.row (main row) -->

    </section>
        <!--内容结束-->
    </div>
</div>
  <include file="common/bottom" />


</body>
</html>    